<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<span style="display: block;">测试页面1</span>
<button style="display: block;margin-bottom: 30px;" onclick="callChilds();">测试按钮</button>
<div>发送的信息是：<input id="iframe" type="text" value="parent message"><input id="sendBtn" type="button" value="发送"></div>
<script>
    // 点击按钮后向iframe页面发送数据
    document.getElementById('sendBtn').onclick = function () {
        // window.frames[0]代表第一个iframe页面
        window.frames[0].postMessage(document.getElementById("iframe").value, '*');
    }
</script>
<div>
    <p>我是父页面</p>
    <p>接收到的iframe信息是：<span id="content"></span></p>
    <script>
        // event 参数中有 data 属性，就是iframe页面发送过来的数据
        window.addEventListener("message", function (event) {
            // 把iframe页面发送过来的数据显示在父页面中
            document.getElementById("content").innerHTML = event.data;
        }, false);
    </script>
</div>
<script>
    function callChilds() {
        var iframes = document.getElementsByTagName("iframe");
        for (var i = 0; i < iframes.length; i++) {
            var contentWindow = iframes[i].contentWindow;

            window.frames[0].postMessage('parent', '*');
        }
    }

    function callLocalJs() {
        window.NativeLog.log("12345");
    }
</script>
<iframe src="http://simenhi.gitee.io/downgit/crosstest/test2.html" width="500px" height="500px"></iframe>
</body>
</html>